home *** CD-ROM | disk | FTP | other *** search
/ NetObjects Fusion 7 / Fusion7.iso / NetObjects Fusion / data1.cab / Language_Resource_-_English / Components / AdBanner / TearTransition.class (.txt) < prev    next >
Encoding:
Java Class File  |  2002-10-18  |  2.2 KB  |  76 lines

  1. import java.awt.image.MemoryImageSource;
  2.  
  3. public class TearTransition extends BannerTransition {
  4.    static final float INITIAL_X_CROSS = 1.6F;
  5.    static final float X_CROSS_DIVISOR = 3.5F;
  6.    float xCross;
  7.  
  8.    public TearTransition() {
  9.       super.numOfFrames = 7;
  10.    }
  11.  
  12.    public void finishInit() {
  13.       System.arraycopy(super.owner.banners[super.owner.currentBanner].imagePixels, 0, super.workPixels, 0, super.imageWidth);
  14.       System.arraycopy(super.owner.banners[super.owner.nextBanner].imagePixels, super.imageWidth, super.workPixels, super.imageWidth, super.pixelsPerImage - super.imageWidth);
  15.       this.xCross = 1.6F;
  16.  
  17.       for(int i = super.numOfFrames - 1; i >= 0; --i) {
  18.          try {
  19.             Thread.sleep(100L);
  20.          } catch (InterruptedException var6) {
  21.          }
  22.  
  23.          this.Tear();
  24.  
  25.          try {
  26.             Thread.sleep(150L);
  27.          } catch (InterruptedException var5) {
  28.          }
  29.  
  30.          super.frames[i] = super.owner.createImage(new MemoryImageSource(super.imageWidth, super.imageHeight, super.workPixels, 0, super.imageWidth));
  31.          super.owner.prepareImage(super.frames[i], super.owner);
  32.          this.xCross /= 3.5F;
  33.       }
  34.  
  35.       super.workPixels = null;
  36.    }
  37.  
  38.    public void Tear() {
  39.       int heightAdder;
  40.       int p = heightAdder = super.imageWidth;
  41.  
  42.       for(int y = 1; y < super.imageHeight; ++y) {
  43.          float hMulti = this.xCross * (float)y;
  44.          if (hMulti >= 0.5F) {
  45.             float fx = 0.0F;
  46.             ++hMulti;
  47.             int x = 0;
  48.  
  49.             do {
  50.                super.workPixels[p++] = super.owner.banners[super.owner.currentBanner].imagePixels[heightAdder + x];
  51.                x = (int)(fx += hMulti);
  52.             } while(x < super.imageWidth);
  53.          } else {
  54.             float overflow = 1.0F / hMulti;
  55.             float dstEnd = overflow / 2.0F + 1.5F;
  56.             int dstStart = 0;
  57.             int src_offset = 0;
  58.  
  59.             for(int length = (int)dstEnd; dstStart + src_offset + length < super.imageWidth; length = (int)dstEnd - dstStart) {
  60.                System.arraycopy(super.owner.banners[super.owner.currentBanner].imagePixels, p + src_offset, super.workPixels, p, length);
  61.                ++src_offset;
  62.                dstEnd += overflow;
  63.                p += length;
  64.                dstStart += length;
  65.             }
  66.  
  67.             int var13 = super.imageWidth - src_offset - dstStart;
  68.             System.arraycopy(super.owner.banners[super.owner.currentBanner].imagePixels, p + src_offset, super.workPixels, p, var13);
  69.          }
  70.  
  71.          p = heightAdder += super.imageWidth;
  72.       }
  73.  
  74.    }
  75. }
  76.